package com.fastloan.mgt.application.contract.service.impl.loanmode.mode.kd;

import com.fastloan.common.model.CheckResult;
import com.fastloan.mgt.application.base.enums.ApplicationStatusEnum;
import com.fastloan.mgt.application.contract.enums.LoanModeEnum;
import com.fastloan.mgt.application.contract.model.ApplicationContract;
import com.fastloan.mgt.application.contract.model.ApplicationLoanResult;
import com.fastloan.mgt.application.contract.service.impl.loanmode.LoanMode;
import com.fastloan.mgt.application.repay.model.vo.AppCurrRepayExt;
import com.fastloan.mgt.application.repay.service.ZyApplicationRepaymentPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 快贷模式放款
 *
 * @author yanwe
 * createTime 2018-01-2018/1/8 15:56
 */
@Component
public class KdMode extends LoanMode {

    @Autowired
    private ZyApplicationRepaymentPlanService applicationRepaymentPlanService;

    @Override
    public CheckResult loan(ApplicationContract applicationContract) {
        applicationRepaymentPlanService.insertRepaymentPlan(getApplication(applicationContract.getApplicationId())
                , getProduct(applicationContract.getApplicationId()), applicationContract);
        applicationService.modifyApplicationStatus(applicationContract.getApplicationId(), ApplicationStatusEnum.IS_SIGNED);
        return CheckResult.success();
    }

    @Override
    public CheckResult repayment(String applicationId) {
        return null;
    }

    @Override
    protected CheckResult processCallback(ApplicationLoanResult applicationLoanResult) {
        return CheckResult.success();
    }


    @Override
    public LoanModeEnum loanMode() {
        return LoanModeEnum.KD;
    }

    @Override
    public CheckResult updateApplicationList(AppCurrRepayExt application) {
        return null;
    }
}
